﻿<cfsilent>
	<cfscript>
		
		sessionAdvice = getProperty("serviceFactory").getBean("sessionAdvice");
		depId = sessionAdvice.getUserProp("teacherDepartment");
		
		sql = "SELECT 
					b.institute_id, 
					b.institute_name  
				FROM t_class 
					 INNER JOIN t_subject a ON a.sbj_id = t_class.sbj_id  
					 INNER JOIN t_institute b ON b.institute_id = a.institute_id 
				WHERE b.institute_id = :depId 
				GROUP BY 
					b.institute_id, b.institute_name 
				ORDER BY b.institute_name ";
		queryObj = new Query( datasource=application.dnsSlave ) ;
		queryObj.addParam( name="depId", value=depId, cfsqltype="cf_sql_varchar" );
		rs_ins = queryObj.execute( sql=sql ).getResult();
		
		dictAdvice = getProperty("serviceFactory").getBean("senateDictionaryAdvice");
		datetimeAdvice = getProperty("serviceFactory").getBean("datetimeAdvice");
		propertyAdvice = getProperty("serviceFactory").getBean("studentPropertyAdvice");
		
		event.setArg("pageTitle", "教学运行基础数据 - 学生学籍管理");
		
		currentTab = event.getArg("TabID", "labDepartment");
		
		targetArgs = structNew();
		passArgs = structNew();
		
		/* 搜索学生档案 */
		keyword = event.getArg("Keywords");
		
		rs_student = queryNew("stu_id");
		
		if ( len(keyword) ) {
			
			
			sql = "SELECT 
						  a.stu_id, a.stu_name, 
						  t_nation.nation_name, t_student_status.student_prop 
					FROM t_student a 
						 INNER JOIN t_nation ON t_nation.nation_code = a.nation_code 
						 INNER JOIN t_student_status ON t_student_status.stu_id = a.stu_id  
						 INNER JOIN t_class ON t_class.cls_id = a.cls_id 
						 INNER JOIN t_subject ON t_class.sbj_id = t_subject.sbj_id 
					WHERE 
						 t_subject.institute_id  = :depId 
					AND 
					(
						a.stu_id LIKE :condition 
						OR 
						a.stu_name LIKE :condition 
					)
					ORDER BY a.stu_name ";
			queryObj = new Query( datasource=application.dnsSlave,maxRows=60  ) ;
			queryObj.addParam( name="depId", value=depId, cfsqltype="cf_sql_varchar" );
			queryObj.addParam( name="condition", value=keyword&"%" , cfsqltype="cf_sql_varchar" );
			rs_student = queryObj.execute( sql=sql ).getResult();
		
		}

	</cfscript>
</cfsilent>

<div id="headArea">
	<div class="uiHeader uiHeaderWithImage ptm">
		<div class="clearfix uiHeaderTop">
			<div class="uiHeaderActions rfloat">
				<a class="uiButton" href="<cfoutput>#buildURL('studentMark')#</cfoutput>"><i class="mrs img btnList"></i><span class="uiButtonText">学生成绩</span></a>
			</div>
			<div>
				<h2 class="uiHeaderTitle">
					<i class="uiHeaderImage img icon16x16 application"></i>学籍档案
				</h2>
			</div>
		</div>
	</div>
</div>

<div class="UIElement">
	<ul class="senateFirstPage">
		<li>
			<div class="clearfix" id="summary">
				<div class="UItab">
					<div class="tabLables">
						<span <cfif currentTab eq "labDepartment">class="active"</cfif> id="labDepartment" tabTarget="Department">学生专业分布</span>
						<span <cfif currentTab eq "labSearch">class="active"</cfif> id="labSearch" tabTarget="Search">搜索学生档案</span>
					</div>
				</div>
				<script language="javascript" type="text/javascript">
					//<![CDATA[
					<!--
					$(document).ready(function() {
						
						/* init Tab */
						$("div.tabContent").hide();
						$("div#" + $("div.tabLables span.active").attr("tabTarget")).show();
						
						$("div.tabLables > span").click(function(){
							var $targetID = $(this).attr("tabTarget");
							
							$("div.tabLables span").removeClass("active");
							$(this).addClass("active");
							
							$("div.tabContent").not('[id="' + $targetID + '"]').hide();
							$("div.tabContent#" + $targetID).show();
						});
						
					});
					// -->
					//]]>
				</script>
				
				<div id="Department" class="tabContent">

                    <cfloop query="rs_ins" >
						
						<div class="noticeBlock">
							<h3><cfoutput>#rs_ins.institute_name#</cfoutput></h3>
							<p><span class="img icon16x16 message"></span>点击专业名称查看行政班分布情况</p>
							<hr/>
						</div>
						
                        <cfset sql = "SELECT 
											  b.sbj_id, b.sbj_name, 
											  b.term_start, b.level_code, 
											  count(a.cls_id) cls_id  
										FROM t_class a 
											 INNER JOIN t_subject b ON a.sbj_id = b.sbj_id 
										WHERE b.institute_id = :depID 
										GROUP BY 
												b.sbj_id, b.sbj_name, b.term_start, b.level_code  
										ORDER BY 
												b.sbj_name " />
						<cfset queryObj = new Query( datasource=application.dnsSlave )/>
                        <cfset queryObj.addParam( name="depID", value=rs_ins.institute_id, cfsqltype="cf_sql_varchar" )/>
                        <cfset rs_subject = queryObj.execute( sql=sql ).getResult()/>
                        
						<div class="clearfix">
							<div class="UICardTable">
                                <cfloop query="rs_subject" >
									<cfset structInsert(targetArgs, "SubID", rs_subject.sbj_id, true) />
									<dl>
										<dt>
											<a href="<cfoutput>#buildURL('studentBySubject', targetArgs)#</cfoutput>">
												<em class="subject"><!--imgholder--></em>
												<dd>
													<h3><cfoutput>#rs_subject.sbj_name#</cfoutput></h3>
													<div><cfoutput>#dictAdvice.getTermEnrol(rs_subject.term_start)#-#dictAdvice.getStudentLevel(rs_subject.level_code)#-#rs_subject.cls_id#个行政班</cfoutput></div>
												</dd>
											</a>
										</dt>
									</dl>
								</cfloop>
							</div>
						</div>
						
					</cfloop>
					
				</div>

				<div id="Search" class="tabContent">
					
					<form id="formSearch" onSubmit="javascript:return processVerfiyForm('formSearch');" class="formWrapper Transparent" method="post" action="<cfoutput>#buildURL('studentProfile')#</cfoutput>">
						<input type="hidden" name="TabID" value="labSearch" />
						
						<div class="label">
							<b>学号或姓名</b>
							<input name="Keywords" id="Keywords" type="text" class="typeText" verification="required" maxlength="128" value="<cfoutput>#event.getArg('Keywords')#</cfoutput>" />
						</div>
						<hr/>
						<div class="lable">
							<input class="button1" type="submit" value="搜索" />
						</div>
					</form>
					
					<cfif rs_student.recordCount>

						<div class="clearfix">
							<div class="UICardTable">
                                <cfloop query="rs_student" >
									
									<cfset structInsert(passArgs, "STU", rs_student.stu_id, true) />
									<cfset propertyAdvice.parseProperty(rs_student.student_prop) />
									
									<dl <cfif not propertyAdvice.getInSchool()>class="disabled"</cfif>>
										<dt>
											<a href="<cfoutput>#buildURL('studentProfileView', passArgs)#</cfoutput>">
												<em class="people"><!--imgholder--></em>
												<dd>
													<h3><cfoutput>#rs_student.stu_name#</cfoutput> (<cfoutput>#rs_student.nation_name#</cfoutput>)</h3>
													<p><cfoutput>#rs_student.stu_id#</cfoutput></p>
												</dd>
											</a>
										</dt>
									</dl>
								</cfloop>					
							</div>
						</div>
					
					</cfif>
					
				</div>

			</div>
		</li>
	</ul>
</div>



